package Demo1.dao;

import Demo1.bean.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

//public class StudentServiceImpl implements StudentMapper {
 /*   @Override
    @Test
    public  Student selectById(Integer id) {
        Student stu =null;
        SqlSession sqlSession = null;
        InputStream is =null;
        try {
            is = Resources.getResourceAsStream("MyBatisConfig.xml");

            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);

            sqlSession = sqlSessionFactory.openSession(true);

            //获取StudentMapper接口的实现类对象
            // StudentMapper mapper = new StudentMapperImpl();
            StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);

             stu = mapper.selectById(id);


        } catch (IOException e) {

        } finally {
            if (sqlSession != null) {
                sqlSession.close();
            }
            if(is!=null){
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return stu;
    }}*/

